package com.hgl.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 
 * @author:HGL
 * ClassName:com.hgl.filter.MyFilter.java
 * Date:2020年8月6日下午3:16:51
 * Version:1.0
 */

public class MyFilter implements Filter{
//初始化
	private static Logger log=LoggerFactory.getLogger(MyFilter.class);
	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub
		
	}

//过滤的方法
	@Override
	public void doFilter(ServletRequest arg0, ServletResponse arg1,
			FilterChain arg2) throws IOException, ServletException {
		HttpServletRequest request=(HttpServletRequest) arg0;
//		System.out.println("MyFilter start"+request.getRequestURL());
		log.debug("MyFilter start"+request.getRequestURL());
		arg2.doFilter(arg0, arg1);
//		System.out.println("MyFilter end");
		log.debug("MyFilter end");
		
	}
	
	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

}
